<template>
  <k-form-modal
    width="middle"
    title="订单备注"
    v-bind="formModalState"
    v-on="formModalEvent"
  >
    <el-form-item label-width="0px" prop="remark">
      <el-input
        v-model="state.model.remark"
        maxlength="200"
        allow-clear
        placeholder="请填写编辑内容"
        show-word-limit
        type="textarea"
        rows="6"
      />
    </el-form-item>
  </k-form-modal>
</template>

<script setup lang='ts'>
import { ref, reactive } from 'vue';
import { useFormModal } from '@crud/index';
import { invoiceRemark } from '@/api/crm-agency/kgj/invoice';
import { ElMessage } from 'element-plus';
defineOptions({
  name: 'KgjInvestClaimPoolModalRemark'
});
const emits = defineEmits(['success']);
const { state, formModalState, formModalEvent, ...methods } = useFormModal({
  model: {
    remark: '',
    invoice_id: undefined
  },
  rules: {
    remark: [{ required: true, message: '请填写编辑内容' }]
  },
  onShow: (mode = 0, data: any) => {
    if (data) {
      state.model = {
        ...state.model,
        remark: data.remark || '',
        invoice_id: data.invoice_id
      };
    }
  },
  onSubmit: async (model: any, mode = 0) => {
    if (mode === 1) {
      const res = await invoiceRemark(model);
      if (!res.err) {
        ElMessage.success('修改成功');
        emits('success');
      }
      return res;
    }

  }
});

defineExpose({
  show: methods.show
});
</script>
